package com.steak.concurrent.lock.reentrantwriteandreadlock;

import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * @author 刘牌
 * @Title:
 * @date 2022/2/2312:26
 */
public class WriteAndReadLockTest {
    public static void main(String[] args) {
        ThreadSafeReadWriteArrayList<Object> list = new ThreadSafeReadWriteArrayList<>();
        for (int i = 0 ; i < 100000 ; i++){
            int finalI = i;
            new Thread(() -> {
                list.add(""+ finalI);
            }).start();
        }
        for (int j = 0 ; j < 100000 ; j++){
            int finalJ = j;
            new Thread(() -> {
                System.out.println(list.get(finalJ));
            }).start();
        }
    }
}
